import { Component } from '@angular/core';
import {App, IonicPage, NavController, NavParams} from 'ionic-angular';
import {DialogProvider} from "@providers/dialog";
import {StorageProvider} from "@providers/storage";

/**
 * Generated class for the ConsigneeMyPage page.
 *
 * See https://ionicframework.com/docs/components/#navigation for more info on
 * Ionic pages and navigation.
 */

@IonicPage()
@Component({
  selector: 'page-consignee-my',
  templateUrl: 'consignee-my.html',
})
export class ConsigneeMyPage {

  userInfo: any = this.storage.read("userInfo");

  constructor(private app: App,
              public navCtrl: NavController,
              public navParams: NavParams,
              private dialog: DialogProvider,
              private storage: StorageProvider,) {
  }

  ionViewDidLoad() {
    console.log('ionViewDidLoad ConsigneeMyPage');
  }

  ionViewWillEnter() {
    this.userInfo = this.storage.read("userInfo");
  }

  /**
   * 页面跳转
   * @param page
   */
  push(page: string) {
    this.navCtrl.push(page);
  }

  /**
   * 退出登录
   * @param page
   */
  logout(page: string) {
    this.dialog.showConfirm(() => {
      this.storage.write("userInfo", {});
      this.app.getRootNav().setRoot(page);
    }, "是否退出登录？")
  }

}
